//
//  TCDateFormatter.swift
//  SwiftTestDemo
//
//  Created by John on 2018/5/22.
//  Copyright © 2018年 company. All rights reserved.
//

import UIKit

class TCDateFormatter: NSObject {

    static var def_YearMonthDayWeekChn:String                = "yyyy年MM月dd日 EEEE"
    static var def_YearMonthDayWeekChn_DF:String             = "yyyy年MM月dd日 EE"
    static var def_Year1Month1DayWeekChn_DF:String           = "yyyy年M月d日 EE"
    static var def_Year1Month1Day_DF:String                  = "yyyy年M月d日"
    static var def_YearMonthDayChn_DF:String                 = "yyyy年MM月dd日"
    static var def_MonthYearChn_DF:String                    = "MM月/yyyy年"
    static var def_YearWeekChn_DF:String                     = "yyyy年 EEEE"
    static var def_MonthDayWeekTwoChn_DF:String              = "MM月dd日 EE"
    static var def_MonthDayLineWeekTwoChn_DF:String          = "MM-dd EE"
    static var def_MonthDayWeekChn_DF:String                 = "M月d日 EE"
    static var def_WeekMonthDayChn_DF:String                 = "EE M月d日"
    static var def_MonthDayChn_DF:String                     = "M月d日"
    static var def_YearMonthDayHourMinuteChn_DF:String       = "yyyy年MM月dd日 HH:mm"
    static var def_YearMonthDayHourMinuteSecChn_DF:String    = "yyyy年MM月dd日 HH:mm:ss"
    static var def_MonthDayHourMinuteSec_DF:String           = "MM月dd日 HH:mm"
    static var def_GangYearMonth:String                      = "yyyy/MM"
    static var def_GangYearMonthDayHourMinute_DF:String      = "yyyy/MM/dd HH:mm"
    static var def_YearMonthDayHourMinute_DF:String          = "yyyy-MM-dd HH:mm"
    static var def_YearMonthDayHourMinuteSec_DF:String       = "yyyy-MM-dd HH:mm:ss"
    static var def_YearMonthDayHourMinuteSecMinSec_DF:String = "yyyy-MM-dd HH:mm:ss.SSS"
    static var def_YearMonthDayWeek:String                   = "yyyy-MM-dd EEEE"
    static var def_YearMonthDayWeek_DF:String                = "yyyy-MM-dd EE"
    static var def_YearMonthDay:String                       = "yyyyMMdd"
    static var def_YearMonthDay_DF:String                    = "yyyy-MM-dd"
    static var def_MonthDayChn_DFSELFTRIP:String             = "yyyy-MM-dd"
    static var def_YearMonthDayHourMinute:String             = "yyyy-M-d HH:mm"
    static var def_WeekYearMonthDay_DF:String                = "EE yyyy-MM-dd"
    static var def_Year1Month1Day:String                     = "yyyy-M-d"
    static var def_YearMonth:String                          = "yyyy-MM"
    static var def_MonthDay:String                           = "MM-dd"
    static var def_HourMinuteSecond_DF:String                = "HH:mm:ss"
    static var def_HourMinute_DF:String                      = "HH:mm"
    static var def_Hour_DF:String                            = "HH"
    static var def_Hour_DF_Single:String                     = "H"
    static var def_MonthYear:String                          = "MM/YY"
    static var def_MonthDay_DF:String                        = "MM/dd"
    static var def_MonthDayPoint_DF:String                   = "MM.dd"
    static var def_MonthDayLine_DF:String                    = "MM-dd"
    static var def_JustWeek_DF:String                        = "EE"
    static var def_JustWeekFull_DF:String                    = "EEEE"
    static var def_Month:String                              = "M"
    static var def_MonthDayHourMS_DF:String                  = "MM月d日 HH:mm"
    static var def_MDayHourMS_DF:String                      = "M月d日 HH:mm"
    static var def_MDayHourMS_week_DF:String                 = "MM月dd日 EE HH:mm"
    static var def_Year_DF:String                            = "yyyy"
    static var def_MonthDayCH_DF:String                      = "MM月dd日"
    static var def_YearNoZeroMonthDayHourMinuteChn_DF:String = "yyyy年M月d日 HH:mm"
    
    class func dateToStringCustom(_ date:Date , _ formatString:String) -> (String?){
        
        return date.stringWithDateFormat(formatString)
        
    }
    
    class func stringToDateCustom(_ dateString:String , _ formatString:String) -> (Date?) {
        
        return dateString.dateWithDateFormat(formatString)
        
    }
    
    class func dateToDateCustom(_ date:Date , _ fromFormatString:String , _ toFormatString:String) -> (Date?) {
        
        let sDate:String? = self.dateToStringCustom(date, fromFormatString)
        
        let aDate:Date? = self.stringToDateCustom(sDate!, toFormatString)
        
        return aDate
        
    }
    
    class func stringToStringCustom(_ dateString:String , _ fromFormatString:String , _ toFormatString:String) -> String?{
        
        let aDate:Date? = self.stringToDateCustom(dateString, fromFormatString)
        
        let sDate:String? = self.dateToStringCustom(aDate!, toFormatString)
        
        return sDate
        
    }
    
}
